package com.woniu.owner.controller;

import com.woniu.common.ResponseData;
import com.woniu.owner.entity.MaintenanceInfo;
import com.woniu.owner.service.MaintenanceInfoService;
import com.woniu.owner.service.ScmspOwnerRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/repair")
public class RepairController {
    @Autowired
    private ScmspOwnerRepairService scmspOwnerRepairService;
    @Autowired
    private MaintenanceInfoService maintenanceInfoService;

    /**
     * 查询维修项目
     *
     * @return
     */
    @GetMapping("/queryAllRepair")
    public ResponseData<?> queryAllRepair() {
        return scmspOwnerRepairService.queryAllRepair();
    }

    /**
     * 增加维修记录
     *
     * @param maintenanceInfo
     * @return
     */
    @PostMapping("/addMaintenanceInfo")
    public ResponseData<?> addMaintenanceInfo(@RequestBody MaintenanceInfo maintenanceInfo) {
        return maintenanceInfoService.addMaintenanceInfo(maintenanceInfo);
    }

    /**
     * 查询维修记录
     *
     * @return
     */
    @GetMapping("/queryMaintenanceInfo")
    public ResponseData<?> queryMaintenanceInfo(@RequestParam String phone) {
        return maintenanceInfoService.queryMaintenanceInfo(phone);
    }

    /**
     * 修改维修记录
     *
     * @param maintenanceInfo
     * @return
     */
    @PostMapping("/updateMaintenanceInfo")
    public ResponseData<?> updateMaintenanceInfo(@RequestBody MaintenanceInfo maintenanceInfo) {
        return maintenanceInfoService.updateMaintenanceInfo(maintenanceInfo);
    }

    /**
     * 撤销维修记录
     *
     * @return
     */
    @GetMapping("/deleteMaintenanceInfo")
    public ResponseData<?> deleteMaintenanceInfo(@RequestParam Integer id) {
        return maintenanceInfoService.deleteMaintenanceInfo(id);
    }
}
